package net.tools;

import net.gui.Accueil;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

public class AddStatut {

	protected Shell AddStatut;
	private Text txtNewStatut;

	/**
	 * Launch the application.
	 * 
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			AddStatut window = new AddStatut();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		AddStatut.open();
		AddStatut.layout();
		while (!AddStatut.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		Display display = Display.getCurrent();
		AddStatut = new Shell(display, SWT.APPLICATION_MODAL | SWT.CLOSE);
		AddStatut.setSize(450, 300);
		AddStatut.setImage(SWTResourceManager.getImage(Accueil.class, "/images/favicon.ico"));
		AddStatut.setBackground(SWTResourceManager.getColor(247, 244, 227));
		AddStatut.setText("Ajouter un Statut");

		Label lblNouveauStatut = new Label(AddStatut, SWT.NONE);
		lblNouveauStatut.setBounds(35, 100, 97, 15);
		lblNouveauStatut.setBackground(SWTResourceManager.getColor(247, 244, 227));
		lblNouveauStatut.setText("Nouveau statut :");

		txtNewStatut = new Text(AddStatut, SWT.BORDER);
		txtNewStatut.addVerifyListener(new VerifyListener() {
			public void verifyText(VerifyEvent arg0) {
				if (!Character.isAlphabetic(arg0.character))
					arg0.doit = false;
			}
		});
		txtNewStatut.setBounds(165, 97, 192, 21);

		Button btnAjouter = new Button(AddStatut, SWT.NONE);
		btnAjouter.setBounds(271, 236, 75, 25);
		btnAjouter.setText("Ajouter");

		Button btnAnnuler = new Button(AddStatut, SWT.NONE);
		btnAnnuler.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseUp(MouseEvent e) {
				AddStatut.close();
			}
		});
		btnAnnuler.setBounds(359, 236, 75, 25);
		btnAnnuler.setText("Annuler");
	}

}
